// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.znet;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import zombie.Lua.LuaEventManager;
import zombie.core.textures.Texture;
import zombie.network.GameClient;
import zombie.network.GameServer;

public class SteamFriends {
    public static final int k_EPersonaStateOffline = 0;
    public static final int k_EPersonaStateOnline = 1;
    public static final int k_EPersonaStateBusy = 2;
    public static final int k_EPersonaStateAway = 3;
    public static final int k_EPersonaStateSnooze = 4;
    public static final int k_EPersonaStateLookingToTrade = 5;
    public static final int k_EPersonaStateLookingToPlay = 6;

    public static void init() {
        if (SteamUtils.isSteamModeEnabled()) {
            n_Init();
        }
    }

    public static void shutdown() {
        if (SteamUtils.isSteamModeEnabled()) {
            n_Shutdown();
        }
    }

    public static native void n_Init();

    public static native void n_Shutdown();

    public static native String GetPersonaName();

    public static native int GetFriendCount();

    public static native long GetFriendByIndex(int index);

    public static native String GetFriendPersonaName(long steamID);

    public static native int GetFriendPersonaState(long steamID);

    public static native boolean InviteUserToGame(long friendSteamID, String connectString);

    public static native void ActivateGameOverlay(String dialog);

    public static native void ActivateGameOverlayToUser(String dialog, long steamID);

    public static native void ActivateGameOverlayToWebPage(String url);

    public static native void SetPlayedWith(long steamID);

    public static native void UpdateRichPresenceConnectionInfo(String status, String connectString);

    public static List<SteamFriend> GetFriendList() {
        ArrayList arrayList = new ArrayList();
        int int0 = GetFriendCount();

        for (int int1 = 0; int1 < int0; int1++) {
            long _long = GetFriendByIndex(int1);
            String string = GetFriendPersonaName(_long);
            arrayList.add(new SteamFriend(string, _long));
        }

        return arrayList;
    }

    public static native int CreateSteamAvatar(long steamID, ByteBuffer data);

    private static void onStatusChangedCallback(long _long) {
        if (GameClient.bClient || GameServer.bServer) {
            LuaEventManager.triggerEvent("OnSteamFriendStatusChanged", Long.toString(_long));
        }
    }

    private static void onAvatarChangedCallback(long _long) {
        Texture.steamAvatarChanged(_long);
    }

    private static void onProfileNameChanged(long var0) {
    }
}
